home *** CD-ROM | disk | FTP | other *** search
- Path: library.erc.clarkson.edu!rpi!not-for-mail
- From: Tony Cook <tony@online.tmx.com.au>
- Newsgroups: comp.lang.c++,comp.lang.c++.moderated
- Subject: Re: Argc & Argv
- Date: 28 Feb 1996 22:33:40 -0000
- Organization: Home
- Sender: cppmods@netlab.cs.rpi.edu
- Approved: Dietmar.Kuehl@uni-konstanz.de
- Message-ID: <4h2l84$ced@netlab.cs.rpi.edu>
- References: <4gta9f$df5@netlab.cs.rpi.edu>
- NNTP-Posting-Host: netlab.cs.rpi.edu
- X-Original-Date: Thu, 29 Feb 1996 09:26:16 +1100
-
- Rick Richert (richert@butch.lmsc.lockheed.com) wrote:
- : >> I tried posting this last week and am not sure if it was posted or
- : >> not. Soooo, I'm trying again.
-
- : I have some global objects defined outside the main routine and I would
- : like to pass the argc and argv values to their constructors. For example,
- :
- :
- : SomeClass obj( argc, argv);
- :
- : int main( int argc, char **argv) {
- :
- : blah, blah, blah
- :
- : }
- :
- : Unfortunately, the compiler tells me that argc and argv are not defined
- : or else not available for obj.
- :
- : Currently, I get around this problem by creating the global obj and then
- : inside of main, I initialize obj via a method that takes argc and argv.
-
- This is the most portable method.
-
- : I would prefer to pass the arg vars to the constructor. Does anyone know
- : how I can pass the arg vars without being inside of main?
-
- Some DOS/Windows compiler supply the argc and argv values global
- variables (Borland and Watcom), but it's hardly portable.
-
- --
- Tony Cook - tony@online.tmx.com.au
- 100237.3425@compuserve.com
-
- [ Articles to moderate: mailto:c++-submit@netlab.cs.rpi.edu ]
- [ Read the C++ FAQ: http://www.connobj.com/cpp/cppfaq.htm ]
- [ Moderation policy: http://www.connobj.com/cpp/guide.htm ]
- [ Comments? mailto:c++-request@netlab.cs.rpi.edu ]
-